package com.inspur.gs.sbssdl.sbyxgl.djjh2.djjh2.front.djpzmx_frm.voactions;
import com.inspur.edp.bef.api.lcp.ILcpFactory;
import com.inspur.edp.bef.api.lcp.IStandardLcp;
import com.inspur.edp.bef.api.services.IBefSessionManager;
import com.inspur.edp.bff.spi.*;
import com.inspur.edp.bef.api.action.*;

import com.inspur.edp.cef.entity.entity.IEntityDataCollection;
import io.iec.edp.caf.commons.utils.SpringBeanUtils;

import java.util.ArrayList;

public class isjhglVOAction extends AbstractFSAction<VoidActionResult> {

	private String[] ids;
	public isjhglVOAction(String[] ids) {

		this.ids = ids;
	}
	@Override
	public void execute() {
		SpringBeanUtils.getBean(IBefSessionManager.class).createSession();
		try {
			ILcpFactory iLcpFactory = SpringBeanUtils.getBean(ILcpFactory.class);
			String djid = "ff554cce-1197-469a-88f1-814f2ed0781d";// 设备点检配置明细id
			IStandardLcp djlcp = iLcpFactory.createLcpByBEId(djid);
			for (String mainid : ids) {
				IEntityDataCollection sbdjpzmx = djlcp.retrieve(mainid).getData().getChilds().get("sbdjpzmx");
				if (!sbdjpzmx.isEmpty()){
					throw new RuntimeException("选择的设备已有点检计划");
				}
			}
		} finally {
			SpringBeanUtils.getBean(IBefSessionManager.class).closeCurrentSession();
		}
	}
}
